﻿using System;

namespace ThresholdAssistant.Enums.Extensions
{
    /// <summary>
    /// 企微RobotType字符串类型扩展
    /// </summary>
    public static class StringExtensions
    {
        /// <summary>
        /// 企微机器人RobotType转换机器人协议
        /// </summary>
        /// <param name="robotType">机器人robotType</param>
        /// <returns></returns>
        public static RobotProtocolType ToRobotProtocolType(this string robotType)
        {
            switch (robotType)
            {
                case "ipad":
                    return RobotProtocolType.iPad;
                case "iphone":
                    return RobotProtocolType.iPhone;
                case "android_emulator":
                    return RobotProtocolType.AndroidSimulator;
                case "android":
                    return RobotProtocolType.Android;
                case "android_box":
                    return RobotProtocolType.android_box;
                case "windows":
                    return RobotProtocolType.windows;
                case "windows_guard":
                    return RobotProtocolType.windows_guard;
                case "android_cloud":
                    return RobotProtocolType.cloud_protocol;
                case "windows_local":
                    return RobotProtocolType.windows_local;
            }
            throw new ArgumentException("ToRobotProtocolType参数robotType异常");
        }

        /// <summary>
        /// 企微机器人RobotType转换设备类型
        /// </summary>
        /// <param name="robotType">机器人robotType</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException"></exception>
        public static DeviceType ToDeviceType(this string robotType)
        {
            switch (robotType)
            {
                case "ipad":
                    return DeviceType.WorkWeixin_iPad;
                case "iphone":
                    return DeviceType.WorkWeixin_iPhone;
                case "android_emulator":
                    return DeviceType.WorkWeixin_Xposed;
                case "android":
                    return DeviceType.WorkWeixin_Android;
                case "android_box":
                    return DeviceType.WorkWeixin_Xposed;
                case "windows":
                    return DeviceType.WorkWeixin_Windows;
                case "android_cloud":
                    return DeviceType.WorkWeixin_AndroidCloud;
                case "windows_local":
                    return DeviceType.WorkWeixin_WindowsLocal;
                case "android_voley_cloud":
                    return DeviceType.WorkWeixin_AndroidVoleyCloud;
            }
            throw new ArgumentException("ToDeviceType参数robotType异常");
        }

    }
}
